<template>
	<view class="navbarLayout">
		<view class="navbar">
			<view class="statusBar" :style="{height:statusBarHeight + 'px'}"></view>
			<view class="titleBar" :style="{height:titleBarHeight + 'px'}">
				<vire class="title spin">{{title}}</vire>
				<view class="search" @click="onSearch" v-if="showSearch">
					<uni-icons class='icon-search' type="search" size="20" color="#888"></uni-icons>
					<text class="text">搜索</text>
				</view>
			</view>
		</view>
		<view class="fill" :style="{height:navBarHeight+ 'px'}">

		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		computed,
		onMounted
	} from "vue"
	import {
		onLoad,
		onReady,
		onPageScroll,
		onShow,
		onReachBottom
	} from "@dcloudio/uni-app"
	import {
		getStatusBarHeight,
		getTitleBraHeight,
		getNavbarHeight
	} from '@/utils/system.js'

	defineProps({
		title: {
			type: String,
			default: '标题'
		},
		showSearch: {
			type: Boolean,
			default: true
		}
	})

	const statusBarHeight = computed(() => getStatusBarHeight())

	const titleBarHeight = computed(() => getTitleBraHeight())

	const navBarHeight = computed(() => getNavbarHeight())

	onShow(() => {
		// console.log('menuButton信息：', menuButton.value);
		// console.log('系统信息：', systemInfo.value);
		// console.log('height:', statusBarHeight);

		// console.log(titleBarHeight.value);
	})

	const onSearch = () => {
		uni.navigateTo({
			url: '/pages/index/search'
		})
	}
</script>

<style lang="scss" scoped>
	.navbarLayout {
		.navbar {
			position: fixed;
			top: 0;
			left: 0;
			width: 100%;
			// 层级
			z-index: 10;
			background:
				linear-gradient(to bottom, transparent, #fff 450rpx),
				linear-gradient(to right, #a8edea 0%, #fed6e3 100%);


			.statusBar {}

			.titleBar {
				display: flex;
				padding: 0 30rpx;
				align-items: center;

				.title {
					font-size: 22px;
					font-weight: 700;
					color: $text-font-color-1;
					animation-duration: 1s;
					animation-fill-mode: both;
				}

				@keyframes spin {
					from {
						transform: rotate(0deg);
					}

					to {
						transform: rotate(360deg);
					}
				}

				.spin {
					animation-name: spin;
				}

				.search {
					width: 220rpx;
					height: 56rpx;
					border-radius: 60rpx;
					backdrop-filter: blur(6px) brightness(90%);
					background-color: rgba(255, 255, 255, 0.66);

					border: 1px solid #fff;
					margin-left: 30rpx;
					color: #999;
					font-size: 28rpx;
					display: flex;
					align-items: center;
					box-shadow: 2px 7px 30px 0px rgba(100, 100, 111, 0.2);

					.icon-search {}

					.text {
						text-align: center;
						margin-left: 10rpx;
					}
				}
			}
		}
	}
</style>